if (Titanium.Platform.name == 'iPhone OS'){
var win = Titanium.UI.currentWindow;
var view2 = Ti.UI.createView({
	backgroundColor:'#13386c'
});

var statusLabel = Titanium.UI.createLabel({
	text:'tap on movie content',
	width:'auto',
	bottom:10,
	font:{fontSize:12,fontFamily:'Helvetica Neue'}
});
win.add(statusLabel);


var title = Titanium.UI.createLabel({
	text:'',
	color:'white',
	width:'auto',
	top:40,
	font:{fontSize:12,fontFamily:'Helvetica Neue'}
});
win.add(title);

var activeMovie = Titanium.Media.createVideoPlayer({
	url:'../'+'0.mp4',
	backgroundColor:'#111',
	movieControlMode: Titanium.Media.VIDEO_CONTROL_EMBEDDED, 
	scalingMode:Titanium.Media.VIDEO_SCALING_MODE_FILL,
	width:250,
	height:200,
	autoplay:true
});

if (Titanium.Platform.osname == "ipad") {
	activeMovie.width = 700;
	activeMovie.height = 500;
}

// The built-in media playback controls look crazy at 100x100 in Android
if (Ti.Platform.name === "android") {
	activeMovie.width = 250;
	activeMovie.height = 250;
}

win.add(activeMovie);

// label 
var movieLabel = Titanium.UI.createLabel({
	text:'',
	width:'auto',
	height:25,
	color:'white',
	font:{fontSize:18,fontFamily:'Helvetica Neue'}
});

// add label to view
activeMovie.add(movieLabel);

// movie click
activeMovie.addEventListener('click',function()
{
	var newText = "";
	newText += " initialPlaybackTime: " + activeMovie.initialPlaybackTime;
	newText += "; playableDuration: " + activeMovie.playableDuration;
	newText += "; endPlaybackTime: " + activeMovie.endPlaybackTime;
	newText += "; duration: " + activeMovie.duration;
	newText += "; currentPlaybackTime: " + activeMovie.currentPlaybackTime;
	statusLabel.text = newText;
});

// label click
movieLabel.addEventListener('click',function()
{
	movieLabel.text = "You clicked the video label. Sweet!";
});

activeMovie.addEventListener('load',function()
{
	// animate label
	var t = Titanium.UI.create2DMatrix();
	t = t.scale(3);
	movieLabel.animate({transform:t, duration:500, color:'red'},function()
	{
		var t = Titanium.UI.create2DMatrix();
		movieLabel.animate({transform:t, duration:500, color:'white'});
	});
});
activeMovie.addEventListener('complete',function()
{
	Ti.API.debug('Completed!');
});

activeMovie.play();

win.addEventListener('close', function() {
	activeMovie.stop();
});

var a = Titanium.UI.createAlertDialog({
	title:'Coming Soon...',
	message:''
});

var flexSpace = Titanium.UI.createButton({
	systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});

var gp = Titanium.UI.createButton({
	title:'Guided Practice',
	width:100,
	style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
var quiz = Titanium.UI.createButton({
	title:'Quiz',
	width:75,
	style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
var flexSpace = Titanium.UI.createButton({
	systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
var fixedSpace = Titanium.UI.createButton({
	systemButton:Titanium.UI.iPhone.SystemButton.FIXED_SPACE,
	width:50
});
win.setToolbar([flexSpace,gp,fixedSpace,quiz,flexSpace]);

gp.addEventListener('click', function()
{
	a.message = '';
	a.buttonNames = ['OK'];
	a.cancel = 1;
	a.show();
});

quiz.addEventListener('click', function()
{
	var tabGroup = Ti.UI.currentWindow.tabGroup;
		tabGroup.setActiveTab(3);
});

}
else{
		 var win = Titanium.UI.currentWindow;
	var quizButton = Titanium.UI.createButton({
		color:'#fff',
		bottom:20,
		width:301,
		height:57,
		font:{fontSize:20,fontWeight:'bold',fontFamily:'Helvetica Neue'},
		title:'Quiz'
	});
	win.add(quizButton);
	quizButton.addEventListener('click', function(){
	var newWindow = Titanium.UI.createWindow({  
    title:'Practice',
    url: 'testTemplate.js'
	});

	Titanium.UI.currentTab.open(newWindow);
	});



var options = {
	contentURL:'../0.mp4',
	
	scalingMode: Titanium.Media.VIDEO_SCALING_MODE_FILL,
	movieControlMode: Titanium.Media.VIDEO_CONTROL_EMBEDDED,
	width:450,
	height:300,
	autoplay:true
};

var activeMovie = Titanium.Media.createVideoPlayer(options);
win.add(activeMovie);

// label 
var movieLabel = Titanium.UI.createLabel({
	text:'',
	width:'auto',
	height:35,
	color:'white',
	font:{fontSize:12,fontFamily:'Helvetica Neue'}
});

// add label to view
activeMovie.add(movieLabel);

// label click
movieLabel.addEventListener('click',function()
{
	movieLabel.text = "";
	movieLabel.text = "mediaControlStyle = " + activeMovie.mediaControlStyle;
});

activeMovie.addEventListener('load', function()
{
	// animate label
	var t = Titanium.UI.create2DMatrix();
	t = t.scale(3);
	movieLabel.animate({transform:t, duration:500, color:'red'},function()
	{
		var t = Titanium.UI.create2DMatrix();
		movieLabel.animate({transform:t, duration:500, color:'white'});
	});
});

activeMovie.addEventListener('complete',function()
{
	if (Ti.Platform.name === 'android') {
		// So you have a chance to see the "completed" dialog.
		win.close();
		dlg.show();
	} else {
		dlg.show();
		win.close();
	}
});

activeMovie.addEventListener('playbackState',function(e){
});

activeMovie.play();

win.addEventListener('close', function() {
	activeMovie.stop();
});

}